package xty.user.service.impl;

import org.springframework.data.mongodb.core.aggregation.Aggregation;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
import xty.user.dao.IMongoUserDao;
import xty.user.entity.User;
import xty.user.service.IMongoUserService;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by XieTianYi on 2019/12/18.
 */
@Service
public class MongoUserServiceImpl implements IMongoUserService {

    @Resource
    private IMongoUserDao mongoUserDao;

    @Override
    public void save(User user) {
        mongoUserDao.save(user);
    }

    @Override
    public void update(User user) {
        mongoUserDao.update(user);
    }

    @Override
    public List<User> find(Query query) {
        System.out.println(query.toString());
        return mongoUserDao.find(query);
    }

    @Override
    public List find(Aggregation aggregation) {
        return mongoUserDao.find(aggregation);
    }

    @Override
    public void delete(String[] ids) {
        for (String id : ids) {
            mongoUserDao.delete(id);
        }
    }
}
